{{- range $key, $value := .CandiVersionMap.k8s }}
  {{- $version := toString $key }}
  {{- if $value.csi.openstack }}
---
image: {{ $.ModuleName }}/{{ $.ImageName }}-{{ $version | replace "." "-" }}
fromImage: common/distroless
import:
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
  add: /src/cinder-csi-plugin
  to: /bin/cinder-csi-plugin
  before: setup
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-binaries-artifact
  add: /relocate
  to: /
  before: install
  includePaths:
  - '**/*'
docker:
  ENTRYPOINT: ["/bin/cinder-csi-plugin"]
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
    {{- if semverCompare ">=1.29" $version }}
from: {{ $.Images.BASE_GOLANG_21_BULLSEYE }}
    {{- else if semverCompare ">=1.27" $version }}
from: {{ $.Images.BASE_GOLANG_20_BUSTER }}
    {{- else if semverCompare ">=1.25" $version }}
from: {{ $.Images.BASE_GOLANG_19_BUSTER }}
    {{- end }}
mount:
- fromPath: ~/go-pkg-cache
  to: /go/pkg
shell:
  beforeInstall:
  - apt update && apt-get install -y --no-install-recommends ca-certificates git make
  install:
  - export GO_VERSION=${GOLANG_VERSION}
  - export GOPROXY={{ $.GOPROXY }}
  - mkdir -p /src
  - git clone {{ $.SOURCE_REPO }}/kubernetes/cloud-provider-openstack.git /src
  - cd /src
  - git checkout tags/{{ $value.csi.openstack }}
  - git config --global user.email "builder@deckhouse.io"
  - export VERSION={{ $value.csi.openstack }}
  - make cinder-csi-plugin
  {{- end }}
{{- end }}
---
{{- $csiBinaries := "/bin/chmod /bin/mount /bin/mkdir /bin/rmdir /bin/umount /bin/findmnt /bin/lsblk /sbin/badblocks /sbin/blockdev /sbin/blk* /sbin/btrfs* /sbin/dumpe2fs /sbin/e2* /sbin/findfs /sbin/fsck* /sbin/fsfreeze /sbin/fstrim /sbin/mke2fs /sbin/mkfs* /sbin/resize2fs /usr/sbin/parted /usr/sbin/xfs*" }}
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-binaries-artifact
from: {{ $.Images.BASE_ALT_DEV }}
shell:
  setup:
    - /binary_replace.sh -i "{{ $csiBinaries }}" -o /relocate
